#include "tree.h"

bool start( char *src_fn, char *tgt_fn )
{
	CUTextFile src_file( src_fn, "r" );
	if( src_file.IsOpen() == false )	return false;

	CUTextFile tgt_file( tgt_fn, "r" );
	if( tgt_file.IsOpen() == false )	return false;

	int num_src_tok = 0;
	int num_tgt_tok = 0;
	int now_line=0;
	while(1)	{
		CUString src_line;
		if( src_file.ReadLine( src_line ) == false ) break;

		CUString tgt_line;
		if( tgt_file.ReadLine( tgt_line ) == false ) break;
		now_line++;

		CUStringListSN src_ls( src_line, " " );
		CUStringListSN tgt_ls( tgt_line, " " );

		num_src_tok += src_ls.GetSize();
		num_tgt_tok += tgt_ls.GetSize();

	}

	if( num_tgt_tok == 0 )	{
		fprintf( stdout, "null tgt file\n" );
	}
	else	{
		fprintf( stdout, "%1.4f\t(%d/%d)\n", (double)num_src_tok/(double)num_tgt_tok, num_src_tok, num_tgt_tok );
	}


	return true;
}


int main( int argc, char *argv[] )
{
	if( argc != 3 )	{
		fprintf( stderr, "usage: tratio src-file tgt-file\n" );
		return 1;
	}

	if( start( argv[1], argv[2] ) == false )	{
		return 1;
	}

	return 0;
}


